package io.yx

import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application

@Composable
@Preview
fun App() {

    var padding by remember { mutableStateOf(10.dp) }

    MaterialTheme {
        Box(
            modifier = Modifier
                .fillMaxSize() // 让Box占满整个屏幕
                .padding(10.dp)
                .background(color = MaterialTheme.colors.background), // 设置背景色
//            contentAlignment = Alignment.Center // 设置内容居中
        ) {

            Column(
                verticalArrangement = Arrangement.Top,
                modifier = Modifier.width(300.dp)
                    .fillMaxHeight()
                    .background(color = Color.White),
            ) {
                Row(
                    verticalAlignment = Alignment.CenterVertically,
                    horizontalArrangement = Arrangement.spacedBy(30.dp),
                    modifier = Modifier.padding(10.dp)
                        .height(30.dp)
                        .background(color = Color.White),
                ) {
                    Text(text = "休息时长")
                    TextField(value = padding.value.toInt().toString(), onValueChange = {
                        if (it.toIntOrNull() != null) {
                            val newValue = Integer.valueOf(it)
                            padding = newValue.dp
                        }
                    })
                }
            }
        }


    }
}

fun main() = application {
    Window(onCloseRequest = ::exitApplication, title = "摸鱼时间", icon = painterResource("touchFish.png")) {
        App()
    }
}
